package com.spark.util;

import java.io.IOException;
import java.net.InetSocketAddress;

import net.spy.memcached.MemcachedClient;

public class MemcachedHelper {
	
	private static MemcachedClient client = null; 
	
	public static void init() throws IOException{
		client = new MemcachedClient(new InetSocketAddress("localhost",11211));
	}
	
	public static void set(String key,int exp, Object o){
		client.set(key, exp, o);
	}
	
	public static Object get(String key){
		if(key == null || "".equals(key.trim())) {
			return null;
		}
		return client.get(key);
	}
	
	public static void delete(String key){
		client.delete(key);
	}
}
